Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): language add ability to define the default language #1704

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

alecarn
Copy link
Collaborator

@alecarn alecarn commented Nov 11, 2024

fix(core): language use the browser language only if the default is not set

The browser language was causing a double loading of the translation files. If we had an French Browser but loading the english version it was loading the French translation then the English. The behavior proposed is: If we provide a DEFAULT lang we use this default otherwise we use the browser language.

If we add the query params lang=en in the browser url, we got duplicated translation files and multiple localization
image

@alecarn alecarn requested a review from pelord November 11, 2024 20:31
@alecarn alecarn self-assigned this Nov 11, 2024
@@ -29,9 +29,14 @@ const TIMEOUT_DURATION = 5000;
/**
* Make sure you only call this method in the root module of your application, most of the time called AppModule.
*/
export function provideTranslation(loader?: Provider): EnvironmentProviders {
export function provideTranslation(
defaultLanguage?: string | undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

au lieu de string, on ne serait pas mieux de basé sur une enum?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'avais mit un Type au début mais après coup vu que cette partie va être utilisé dans d'autre application et librairie, on ne peut connaitre d'avance l'ensemble des langues... Alors je crois que le string est le mieux placés.

fix(core): language use the browser language only if the default is not set
@alecarn alecarn merged commit a3c059e into next Nov 12, 2024
2 checks passed
@alecarn alecarn deleted the fix/language branch November 12, 2024 21:30
@alecarn
Copy link
Collaborator Author

alecarn commented Nov 12, 2024

🎉 This PR is included in version 18.0.0-next.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants